﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		event.setArg("pageTitle", "教学质量评价 - 网上评教进度");
		
		/* 网上评教相关设置 */
		stuDateStart = event.getArg("EVALSYS.STU.DateStart");
		stuDateEnd = event.getArg("EVALSYS.STU.DateEnd");
		
		depId = sessionAdvice.getUserProp("teacherDepartment");
		
		/* 整体评教状态 */
		sql = "SELECT 
				a.state, COUNT(*) counter
				FROM t_student_evaluate a 
				INNER JOIN t_student_course b ON a.scc_id = b.scc_id 
				INNER JOIN t_student c ON c.stu_id = b.stu_id 
				INNER JOIN t_class d ON d.cls_id = c.cls_id 
				INNER JOIN t_subject e ON e.sbj_id = d.sbj_id 
				WHERE 
					e.institute_id = :depId 
				GROUP BY a.state 
				ORDER BY a.state";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );

		rs_chooser = queryObj.execute( sql=sql ).getResult();
		
		
		/* 课程评教进度 */
		sql = "SELECT 
				a.state, COUNT(DISTINCT b.cid) counter 
				FROM t_student_evaluate a 
				INNER JOIN t_student_course b ON a.scc_id = b.scc_id 
				INNER JOIN t_course c ON c.cid = b.cid 
				WHERE 
					c.institute_id = :depId 
				GROUP BY a.state 
				ORDER BY a.state";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_course = queryObj.execute( sql=sql ).getResult();


		/* 学生评教进度 */
		sql = "SELECT 
				a.state, COUNT(DISTINCT b.stu_id) counter
				FROM t_student_evaluate a 
				INNER JOIN t_student_course b ON a.scc_id = b.scc_id 
				INNER JOIN t_student c ON c.stu_id = b.stu_id 
				INNER JOIN t_class d ON d.cls_id = c.cls_id 
				INNER JOIN t_subject e ON e.sbj_id = d.sbj_id 
				WHERE 
					e.institute_id = :depId 
				GROUP BY a.state 
				ORDER BY a.state";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_student = queryObj.execute( sql=sql ).getResult();
		
		/* 图表数据 A-整体进度 C-课程 S-学生 */
		statStruct = {};
		levelArray = [];
		
		summer = 0;
		
		for ( a=1; a LTE rs_chooser.recordCount; a++ ) {
			arrayAppend( levelArray, rs_chooser["state"][a] );
			structInsert( statStruct, "A-" & rs_chooser["state"][a], rs_chooser["counter"][a] );
			summer += rs_chooser["counter"][a];
		}
		
		structInsert( statStruct, "SUM-A", summer );

		summer = 0;
		
		for ( a=1; a LTE rs_course.recordCount; a++ ) {
			structInsert( statStruct, "C-" & rs_course["state"][a], rs_course["counter"][a] );
			summer += rs_course["counter"][a];
		}
		
		structInsert( statStruct, "SUM-C", summer );
		
		summer = 0;
		
		for ( a=1; a LTE rs_student.recordCount; a++ ) {
			structInsert( statStruct, "S-" & rs_student["state"][a], rs_student["counter"][a] );
			summer += rs_student["counter"][a];
		}
		
		structInsert( statStruct, "SUM-S", summer );
		
		currentTab = event.getArg("TabID", "labStatus");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学质量评价</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 bar"></i>网上评教进度
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStatus">class="active"</cfif> id="labStatus" tabTarget="Status">评教进度</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>				
				</script>
				
				<div id="Status" class="tabContent">
				
					<div class="noticeBlock">
						<h3>网上评教执行进度</h3>
						<p><span class="img icon16x16 message"></span>当前学期, 网上评教时间预计从 <em><cfoutput>#datetimeAdvice.formatDateString( stuDateStart )#</cfoutput></em> 开始，至 <em><cfoutput>#datetimeAdvice.formatDateString( stuDateEnd )#</cfoutput></em> 结束.</p>
						<hr/>
					</div>
					
					<table class="UItable">
						<tr class="cellBorder">
							<td>评教状态</td>
							<td colspan="2" align="center">整体进度</td>
							<td colspan="2" align="center">课程进度</td>
							<td colspan="2" align="center">学生进度</td>
						</tr>
						<cfloop array="#levelArray#" index="level">
							<tr class="cellBorder">
								<td><cfoutput>#dictAdvice.getProgressStatus( level )#</cfoutput></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "A-" & level)><cfoutput>#statStruct["A-" & level]#</cfoutput><cfelse>-</cfif></span></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "A-" & level) and structKeyExists(statStruct, "SUM-A") and statStruct["SUM-A"]><cfoutput># numberFormat( 100 * statStruct["A-" & level] / statStruct["SUM-A"], "___.___" )#</cfoutput> %<cfelse>-</cfif></span></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "C-" & level)><cfoutput>#statStruct["C-" & level]#</cfoutput><cfelse>-</cfif></span></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "C-" & level) and structKeyExists(statStruct, "SUM-C") and statStruct["SUM-C"]><cfoutput># numberFormat( 100 * statStruct["C-" & level] / statStruct["SUM-C"], "___.___" )#</cfoutput> %<cfelse>-</cfif></span></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "S-" & level)><cfoutput>#statStruct["S-" & level]#</cfoutput><cfelse>-</cfif></span></td>
								<td align="center"><span class="numeric"><cfif structKeyExists(statStruct, "S-" & level) and structKeyExists(statStruct, "SUM-S") and statStruct["SUM-S"]><cfoutput># numberFormat( 100 * statStruct["S-" & level] / statStruct["SUM-S"], "___.___" )#</cfoutput> %<cfelse>-</cfif></span></td>
							</tr>
						</cfloop>
					</table>
					
					<div class="clearfix mtl mbl"></div>
					
					<div id="container" style="height:400px;"></div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						var chart;
						
						$(document).ready(function() {
							
							chart = new Highcharts.Chart({
								
								chart: {
									renderTo: 'container', 
									type: 'bar'
									},
								
								title: {
									text: null
									},
									
								xAxis: {
									categories: ['整体', '课程', '学生'],
									title: {
										text: null
										}, 
									labels: {
										style: {
											fontSize: '12px'
										}
									}
									},
								yAxis: {
									min: 0,
									title: {
										text: null
										},
									labels: {
										overflow: 'justify'
										}
									},
								tooltip: {
									valueSuffix: null,
									formatter: function() {
										var s;
										if ( this.x == '整体' ) {
											s = this.series.name + '<br/>' + this.y + ' 条选课数据';
										}
										if ( this.x == '课程' ) {
											s = this.series.name + '<br/>' + this.y + ' 门课程';
										}
										if ( this.x == '学生' ) {
											s = this.series.name + '<br/>' + this.y + ' 名学生';
										}
										
										return s;
									}
									},
								plotOptions: {
									bar: {
										dataLabels: {
											enabled: true
											}
										}
									},
								legend: {
									layout: 'vertical',
									align: 'right',
									verticalAlign: 'top',
									x: -40,
									y: 140,
									floating: true,
									borderWidth: 1,
									backgroundColor: '#FFFFFF',
									shadow: true
									},
								credits: {
									enabled: false
									},
								series: [
									<cfset i=0 /><cfloop array="#levelArray#" index="level"><cfset i++ />
									{
									name: '<cfoutput>#dictAdvice.getProgressStatus( level )#</cfoutput>',
									data: [ 
										<cfif structKeyExists(statStruct, "A-" & level)><cfoutput>#statStruct["A-" & level]#</cfoutput><cfelse>0</cfif>,
									 	<cfif structKeyExists(statStruct, "C-" & level)><cfoutput>#statStruct["C-" & level]#</cfoutput><cfelse>0</cfif>,
										<cfif structKeyExists(statStruct, "S-" & level)><cfoutput>#statStruct["S-" & level]#</cfoutput><cfelse>0</cfif>
										]
									}
									<cfif i LT arrayLen(levelArray)>,</cfif>
									</cfloop>
									]	
							});
							
						});
						
						// -->
						//]]>
					</script>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>

